package com.blog.controller;

import com.blog.pojo.PageBean;
import com.blog.pojo.ResultResponse;
import com.blog.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class AdminController {
    @Autowired
    private AdminService adminService;

    @PostMapping("/admin/insert")
    public ResultResponse insertAdmin(@RequestParam Integer id){
        adminService.insertAdmin(id);
        return ResultResponse.success();
    }

    @DeleteMapping("/admin/managers/{id}")
    public ResultResponse deleteAdmin(@PathVariable int id){
        adminService.deleteAdmin(id);
        return ResultResponse.success();
    }

    @GetMapping("/admin/managers")
    public ResultResponse getAdmin(@RequestParam(defaultValue = "1") Integer page){
        Integer pageSize = 10;
        PageBean pageBean = adminService.listAdmins(page, pageSize);
        return ResultResponse.success(pageBean);
    }
}
